package uk.ac.glasgow.demosocs.impl;

import java.util.ArrayList;
import java.util.List;

import uk.ac.glasgow.demosocs.Candidate;
import uk.ac.glasgow.demosocs.ElectionResult;

/**
 * The Class ElectionResultStub represents the results for a given Election in the Voting
 * System.
 * 
 * @author Project Team L
 */
public class ElectionResultStub implements ElectionResult{

	/** The winning candidates. */
	private List<Candidate> winningCandidates;

	/**
	 * Instantiates a new election result stub with default values (empty).
	 */
	public ElectionResultStub(){
		this.winningCandidates = new ArrayList<Candidate>();
	}	
	
	/**
	 * Instantiates a new election result stub.
	 *
	 * @param candidates the candidates
	 */
	public ElectionResultStub(List<Candidate> candidates){
		this.winningCandidates = candidates;
	}
		
	/**
	 * Gets the list of winning candidates for this election.
	 * 
	 * @return A List of Candidates
	 */
	@Override
	public List<Candidate> getWinningCandidates() {
		return this.winningCandidates;
	}
	
	/**
	 * Sets the winning candidates.
	 *
	 * @param winningCandidates the new winning candidates
	 */
	public void setWinningCandidates(List<Candidate> winningCandidates){
		this.winningCandidates = winningCandidates;
	}
	
	public String toString(){
		String results = "";
		
		for (Candidate result : this.winningCandidates){
			results += result.toString() + " ";
		}
		//remove trailing space if its there
		/*if (results.charAt(results.length()) == ' '){
			return results.substring(0, results.length()-1);
		}*/
		return results;
	}
	
	
}